import { registerVueControllerComponents } from '@symfony/ux-vue';
import { createRouter, createWebHistory } from 'vue-router';
import './../styles/app.scss';

registerVueControllerComponents(require.context('./', true, /\.vue$/, 'lazy'));
document.addEventListener('vue:before-mount', (event) => {
    const {
        componentName, // The Vue component's name
        component, // The resolved Vue component
        props, // The props that will be injected to the component
        app, // The Vue application instance
    } = event.detail;

    // Example with Vue Router
    const router = createRouter({
        history: createWebHistory(),
        routes: [
            // { path: '/survey/list', component: ListSurveys },
        ],
    });

    app.use(router);
});


document.addEventListener('vue:mount', (event) => {
    const {
        componentName, // The Vue component's name
        component, // The resolved Vue component
        props, // The props that are injected to the component
    } = event.detail;
});

document.addEventListener('vue:unmount', (event) => {
    const {
        componentName, // The Vue component's name
        props, // The props that were injected to the component
    } = event.detail;
});
